import { useState, useEffect } from 'react'
const useMouse = () => {
  const [position, setPosition] = useState({
    left: 0,
    top: 0,
  })
  useEffect(() => {
    const move = (e) => {
      console.log(1)
      setPosition({
        left: e.pageX,
        top: e.pageY,
      })
    }
    document.addEventListener('mousemove', move)
    return () => {
      document.removeEventListener('mousemove', move)
    }
  }, []) // componentDidMount
  return position
}
export default useMouse
